<load href="__PUBLIC__/datepicker/css/datetimepicker.css" />
<load href="__PUBLIC__/datepicker/js/datetimepicker.js" />
<div id="data_page" class="in_page">
    <div class="panel panel-default">
        <div class="panel-body" style="position: relative">
            <form class="form-inline" onsubmit="return checkSearch()">
                <div class="form-group">
                    <label for="exampleInputName2">用户名</label>
                    <input id="username" value="{$search.username}" type="text" name="username" class="form-control"  placeholder="输入用户名" />
                    <input value="1" type="hidden" name="p" class="form-control" />
                </div>
                <div class="form-group">
                    <label >转入用户</label>
                    <input  id="to_username" value="{$search.to_username}" type="text" name="to_username" class="form-control"  placeholder="输入转入用户" />
                </div>
                <div class="form-group">
                    <label >转入时间</label>
                    <input id="begin_time" value="{$search.begin_time}" type="text" name="begin_time" class="form-control"  placeholder="输入开始时间" />
                    <input id="end_time" value="{$search.end_time}" type="text" name="end_time" class="form-control"  placeholder="输入结束时间" />
                </div>
                <button type="submit" class="btn btn-sm btn-default">搜索</button>
                <div class="btn-group">
                    <button type="button" onclick="resetData()" class="btn btn-sm btn-primary">重置</button>
                </div>
            </form>
            <a style="position: absolute;right:5px;top:5px;" class="btn btn-info btn-sm" href="javascript:void(0)" onclick="showIframe('{:U('/balance/addBill')}','添加转账记录','80%','96%')">添加转账记录</a>
        </div>
    </div>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>#ID</th>
            <th>用户</th>
            <th>转入用户</th>
            <th>账单号</th>
            <th>转入数</th>
            <th>说明</th>
            <th>转入时间</th>
        </tr>
        </thead>
        <volist name="list" id="item">
        <tr>
            <th scope="row">{$item.id}</th>
            <td>{$item.username}</td>
            <td>{$item.to_username}</td>
            <td>{$item.bill_sn}</td>
            <td>{$item.number}</td>
            <td>{$item.description}</td>
            <td  style="text-align: center;width: 140px;">{$item.createdtime|date="Y-m-d H:i",###}</td>
        </tr>
        </volist>
    </table>
    {$page}
</div>

<script>
    $(function(){
        $('#begin_time').datetimepicker({
            lang: 'ch',
            format: 'Y-m-d H:i',
            timepicker: true,
            step:10
        });
        $('#end_time').datetimepicker({
            lang: 'ch',
            format: 'Y-m-d H:i',
            timepicker: true,
            step:10
        });
    })
    function checkSearch(){
        _sdate = $("#begin_time").val();
        _etime = $("#end_time").val();
        if (_sdate != '' && _etime == '') {
            alert('请输入时间条件的结束时间');
            return false;
        }
        if (_sdate == '' && _etime != '') {
            alert('请输入时间条件的开始时间');
            return false;
        }
        if (Date.parse(_sdate) - Date.parse(_etime) > 0) {
            alert('时间条件的开始时间不得大于结束时间');
            return false;
        }
        return true;
    }

    function resetData(){
        $("#username").val("");
        $("#to_username").val("");
        $("#begin_time").val("");
        $("#end_time").val("");
    }
</script>